﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BAL.EstRec
{
    public class RecursoComparer : IEqualityComparer<Recurso>
    {
        public bool Equals(Recurso x, Recurso y)
        {
            // If reference same object including null then return true
            if (object.ReferenceEquals(x, y))
            {
                return true;
            }

            // If one object null the return false
            if (object.ReferenceEquals(x, null) || object.ReferenceEquals(y, null))
            {
                return false;
            }

            // Compare properties for equality
            return (x.idIniciativa == y.idIniciativa && x.idRecurso == y.idRecurso);
        }

        public int GetHashCode(Recurso obj)
        {
            if (object.ReferenceEquals(obj, null))
            {
                return 0;
            }

            int referencehHash =
                obj.idIniciativa == null ? 0 : obj.idIniciativa.GetHashCode();
            int versionHash =
                obj.idRecurso == null ? 0 : obj.idRecurso.GetHashCode();

            return referencehHash ^ versionHash;
        }
    }
}
